import java.util.*;

public class Test15 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] hash = new boolean[n + 1];
            int[][] arr = new int[m + 1][n + 1];
            for (int i = 1; i <= m; i++) {
                int j = in.nextInt();
                int k = in.nextInt();
                arr[i][j] = j;
                arr[i][k] = k;
            }
            Queue<Integer> queue = new LinkedList<>();
            int a = 0;
            for (int i = 1; i <= m; i++) {
                if (arr[i][1] != 0) {
                    a = i;
                    queue.add(arr[i][1]);
                    break;
                }
            }
            if (find(arr, a, 1, queue)) {
                for (int x : queue)
                    System.out.print(x + " ");
            } else {
                System.out.print("-1");
            }

        }
    }

    public static boolean find(int[][] arr, int a, int b, Queue<Integer> queue) {
        int m = arr.length;
        int n = arr[0].length;
        // 找同行中另外一个元素
        for (int i = 1; i < n; i++) {
            if (i != b && arr[a][i] != 0) {
                // 将找到的元素入队列
                queue.add(arr[a][i]);
                for (int j = 1; j < m; j++) {
                    if (j != a && arr[j][i] == arr[a][i]) {
                        find(arr, j, i, queue);
                    }
                }
            }

        }
        if (queue.size() == arr.length) {
            return true;
        } else {
            return false;
        }
    }







    public static void main02(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            int[] arr = new int[n];
            int[] brr = new int[n];      // 记录都出现了哪些声部
            int len = 0;
            Map<Integer, Integer> hash = new HashMap<>();
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            for (int i = 0; i < n; i++) {
                hash.put(arr[i], hash.getOrDefault(arr[i], 0) + 1);
                if (len != 0) {
                    if (brr[len - 1] != arr[i] ) {
                        brr[len++] = arr[i];
                    }
                } else {
                    brr[len++] = arr[i];
                }
            }

            if (len > m) { // 如果种类 大于 组数 ，就会出现问题
                System.out.println(-1);
            } else if (m % len == 0) {
                int max = 0;
                for (int i = 0; i < len; i++) {
                    max= Math.max(hash.get(brr[i]), max);
                }
                int k=(m  / len);   // 求 每种 占几组
                int a=max % k ;     // 如果能恰好除尽
                int b=max / k;
                System.out.println(a==0 ? b: a+b);
            } else {
                // 这下面有问题
                int min = n;
                int max = 0;
                for (int i = 0; i < len; i++) {
                    min = Math.min(hash.get(brr[i]), min);
                    max = Math.max(hash.get(brr[i]), max);
                }
                if (max - min > min) {
                    System.out.println(max - min);
                } else {
                    System.out.println(min);
                }
            }
        }
    }









    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int x = in.nextInt();
            int[] arr = new int[x+1];
            int i = 0;
            int sum = 0;
            int a = 1;
            for ( ;a <= x+1; a++) {
                int y=a*a;
                if (y > x) {
                    arr[i++] =y - x ;
                } else {
                    arr[i++] = x - y  ;
                }
                if(i>=2) {
                    if (arr[i - 1] > arr[i - 2]) {
                        a--;
                        sum = Math.min(arr[i-2], arr[i - 1]);
                        if (i >= 3) {
                            if(arr[i - 2] > arr[i - 3])
                                a--;
                            sum = Math.min(sum, arr[i - 3]);
                        }
                        break;
                    }
                }
            }
            if(a*a > x){
                System.out.println(x+sum);
            }else{
                System.out.println(x-sum);
            }

        }
    }
}
